using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace ArchSoft
{
    public partial class ReportFolder : Form
    {

        private string _folder;
        private string _projectFolder;


        CrystalReport3 rpt = new CrystalReport3();
        DataSet1 ds = new DataSet1();
        DataSet1.ReportRow row;
        DataSet1.DevRow row2;


      //  DataSet1.CaptionRow row1;
        public string Folder
        {
            set { _folder = value; }
        }

        public string Project
        {
            set { _projectFolder = value; }
        }

        public ReportFolder()
        {
            InitializeComponent();
        }

        public void LoadInf()
        {
            string path = Path.GetDirectoryName(this._projectFolder) + Path.DirectorySeparatorChar + this._folder;

            string[] kq = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);

            foreach (string file in kq)
            {
                row = ds.Report.NewReportRow();
                row[0] = Path.GetFileNameWithoutExtension(file).ToString();
                row[1] = File.GetLastWriteTime(file).ToString();
                row[2] = File.GetCreationTime(file).ToString();
                row[3] = File.GetLastAccessTime(file).ToString();
                row[4] = this._folder;

                ds.Report.AddReportRow(row);
            }

            //row1 = ds.Caption.NewCaptionRow();
            //row1[0] = Path.GetDirectoryName(this._projectFolder);
            //row1[1] = this._folder;

            //ds.Caption.AddCaptionRow(row1);

        }

        public void LoadDev()
        {
            string Tbx_Dev_Appr = "";
            string Tbx_Dev_chck = "";
            string Tbx_Dev_Des = "";
            string Tbx_Dev_Drw = "";


            string Pat = Path.GetDirectoryName(this._projectFolder) + Path.DirectorySeparatorChar + ProjectManager.PROJECT_INF_FILE;
            if (File.Exists(Pat))
            {
                System.Data.DataTable tbConsl = null;
                DataSet ds1 = new DataSet();
                ds1.ReadXml(Pat);
                tbConsl = ds1.Tables[0];
                if (tbConsl != null)
                {
                    Tbx_Dev_Appr = EncodeDecode.GetDecoded(tbConsl.Rows[15][1].ToString());
                    Tbx_Dev_chck = EncodeDecode.GetDecoded(tbConsl.Rows[16][1].ToString());
                    Tbx_Dev_Des = EncodeDecode.GetDecoded(tbConsl.Rows[17][1].ToString());
                    Tbx_Dev_Drw = EncodeDecode.GetDecoded(tbConsl.Rows[18][1].ToString());

                    row2 = ds.Dev.NewDevRow();
                    row2[0] = Tbx_Dev_Appr;
                    row2[1] = Tbx_Dev_chck;
                    row2[2] = Tbx_Dev_Des;
                    row2[3] = Tbx_Dev_Drw;

                    ds.Dev.AddDevRow(row2);
                }
            }
            else
                return;
        }

        private void ReportFolder_Load(object sender, EventArgs e)
        {
           // SortDataTable(ds.Report);
            rpt.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rpt;
        }
    }
}